<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>room_list.jsp</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">

	<link rel="stylesheet" type="text/css" href="./css/style.css">
	<SCRIPT type="text/javascript">
		function editRoom(){
			var id;			
			var c = document.getElementsByName("choose");
			var i=0;
			for(i=0;i<c.length;i++){
				if(c[i].checked==true){
					id = c[i].value;
					break;
				}
			}
			if(id==null||id==""){
				alert("请选择后再进行修改操作！");
			}else{
				window.location.href="./room/ShowEditRoomAction?id="+id+"&msg=";
			}
		}

		function deleteRoom(){
			var id;			
			var c = document.getElementsByName("check");
			var i=0;
			for(i=0;i<c.length;i++){
				if(c[i].checked==true){
					id = c[i].value;
					break;
				}
			}
			if(id==null||id==""){
				alert("请选择后再进行删除操作！");
			}else{
				$('form1').submit();
			}
		}
	</SCRIPT>
  </head>
  
  <body>
    <div id="blue_button"><div id="blue_button_word">&nbsp;机房列表</div></div>
 	<div id="right_background">&nbsp;<br/> <br/> <br/> 
  <form id="form1" action="./room/DeleteRoomAction" method="post">
	  <table cellspacing="1" class="tab_dept">
		  <tr class="tab_header">
			  <td valign="middle" align="center">机房ID</td>
			  <td valign="middle" align="center">机房名称</td>
			  <td valign="middle" align="center">负责人</td>
			  <td valign="middle" align="center">所属部门 </td>
			  <td valign="middle" align="center">地址</td>
			  <c:if test="${right==3}">
				  <td valign="middle" align="center">修改</td>
				  <td valign="middle" align="center">删除</td>
			  </c:if>
		  </tr>
		  <c:forEach items="${roomList}" var="room">
			  <tr class="row2" onMouseOver="this.className='row1'" onMouseOut="this.className='row2'">
				  <td valign="middle" align="center"><a href="./room/RoomInfoAction?id=${room.roomId}">${room.roomId }</a></td>
				  <td valign="middle" align="center">${room.roomName}</td>
				  <td valign="middle" align="center">${room.comEmp.EName }</td>
				  <td valign="middle" align="center">${room.comDept.dname } </td>
				  <td valign="middle" align="center">${room.roomAddress}</td>
				  <c:if test="${right==3}">
					  <td valign="middle" align="center"><input type="radio" id="choose" name="choose" value="${room.roomId}"/></td>
					  <td valign="middle" align="center"><input type="checkbox" id="check" name="check" value="${room.roomId}"/></td>
				  </c:if>
		  	  </tr>
		   </c:forEach> 
	  </table>
	  <c:if test="${right==3}">
		  <div style="margin-right: 100px" align="right">
		  			<div style="margin-left:20px;" ><font id="msg" color=red>${msg}</font></div>
				  <input type="button" class="add" value="新 增" style="margin-top: 20px; " 
				  			onClick="location.href='./room/ShowNewRoomAction'" />&nbsp;
				  <input type="button" class="del" value="修 改" style="margin-top: 20px;" 
				  			onClick="editRoom()" />&nbsp;
				  <input type="submit" class="add" value="删  除" onclick="deleteRoom()"/>
		  </div>
	  </c:if>
	</form>
	<p class="paging">
		<s:if test="%{currentPage == 1}">
			&lt;&lt; 首页 &lt; 上一页
		</s:if>
		<s:else>
			<a href="./room/RoomListAction?page=1"> &lt;&lt;首页</a>
			<a href="./room/RoomListAction?page=${currentPage-1}">&lt; 上一页 </a>
		</s:else>
	
		<strong>第${currentPage}页/共${totalPages}页</strong>
		<s:if test="%{currentPage == totalPages}">
			下一页 &gt;
			末页 &gt;&gt;
		</s:if>
		<s:else>
			<a href="./room/RoomListAction?page=${currentPage+1}"> 下一页 &gt;</a>
			<a href="./room/RoomListAction?page=${totalPages}">末页 &gt;&gt;</a>
		</s:else>
	</p>
  </div>
  
  </body>
</html>
